package com.cuit.zuke.hotel.client;

import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
class DictFallBack implements FallbackFactory<DictFeignClient> {

    // 原方法异常时，调用该方法
    @Override
    public DictFeignClient create(Throwable throwable) {
        return new DictFeignClient() {
            @Override
            public String getName(String dictCode, String value) {
                String exMsg = throwable.getMessage();
                System.out.println("熔断");
                return "feign method occur hystrix fallback, exception is " + exMsg;
            }

            @Override
            public String getName(String value) {
                String exMsg = throwable.getMessage();
                System.out.println("熔断");
                return "feign method occur hystrix fallback, exception is " + exMsg;
            }

        };
    }
}

